Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate index file #46

Closed

Conversation

Mathieudewet
Copy link
Contributor

WIP (Cleaning).

#!/usr/bin/env node

const { docTitle } = require('../constants');
const chapterHelper = require('../src/helper/chapterHelper');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ processChapter } = require('../src/helper/chapterHelper');


const loadedOutline = jsyaml.safeLoad(readFileSync(`${__dirname}/../config/outline.yaml`, 'utf8'));

const index = `# ${docTitle}\n\n${loadedOutline.map((chapter) => chapterHelper.processChapter(chapter, fileProcessor)).join('\n\n')}`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chapterHelper.processChapter => processChapter

},
};

module.exports = chapterHelper;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you use ES6 modules instead?


const index = `# ${docTitle}\n\n${loadedOutline.map((chapter) => chapterHelper.processChapter(chapter, fileProcessor)).join('\n\n')}`;

writeFile(resolve(__dirname, '../src/pages/docs/index.md'), index, error => error && console.warn(error));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really necessary to generate a Markdown file? Can't we use directly the existing YAML file as a source for Gatsby?

https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-transformer-yaml
gatsbyjs/gatsby#3195

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants